<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <link href="__PUBLIC__/css/Content/index.css" rel="stylesheet" type="text/css" />
    <style>
        #dg{
            height: 100%;;
        }
    </style>
</block>
<block name="bdoy">
    <body>
    <table id="dg"></table>

    <div id="toolbar" style="padding:5px;height:auto">
        <div style="margin-bottom:5px">
            <!--            <a href="#" id="add_button" class="easyui-linkbutton" iconCls="icon-add" plain="true">{:LANG('add')}</a>-->
            <!--            <a href="#" id="edit_button" class="easyui-linkbutton" iconCls="icon-edit" plain="true">{:LANG('edit')}</a>-->
            <!--            <a href="#" id="del_button" class="easyui-linkbutton" iconCls="icon-remove" plain="true">{:LANG('del')}</a>-->
            <a href="#" id="search_button" class="easyui-linkbutton" iconCls="icon-search" plain="true">{:LANG('search')}</a>
                        <a href="#" id="reload_button" class="easyui-linkbutton" iconCls="icon-reload" plain="true">{:LANG('reload')}</a>
            <!--            <a href="#" id="clear_button" class="easyui-linkbutton" iconCls="icon-redo" plain="true">{:LANG('clearSelections')}</a>-->
        </div>
        <div id="queryMaterialsRemovalParamZone">
            <form id="query_form" method="post" action="">
                <table>
                    <tr>
                        <td>{:LANG('csdt_name')}</td>
                        <td><input type="text" class="" name="csdt_name" width="100"/></td>
                        <td>{:LANG('opr')}</td>
                        <td>
                            <select class="easyui-combobox" name="csdt_opr" style="width:200px;">
                                <option value=""></option>
                                <volist name="duty_persons" id="p">
                                    <option value=",{$p['id']},">{$p['realname']}</option>
                                </volist>
                            </select>
                        </td>
                        <td><a id="query_button" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
                        <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#query_form').form('clear');">重置</a></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

    <include file="./Application/Admin/View/block/easyui_window.php" />
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        $(function(){
                var request_url = '__URL__/get_all';
                var add_title = '{:LANG('add')}';
                var edit_title = '{:LANG('edit')}';
                jQuery('#dg').datagrid({
                    fit:true,
                    nowrap: false,
                    striped: true,
                    collapsible:false,
                    url:request_url,
//                queryParams:{page:1,rows:20},
                    method:'get',
                    pageNumber:1,
                    pageSize:{:get_kv_val('admin_page_list_num')},
            pageList:[{:get_kv_val('admin_page_list_num')},50,100,200],
        idField:'id',
            remoteSort: false,
            columns:[[
            {field:'ck',title:'', width:80,checkbox:true,align:'center'},
            {field:'id',title:'ID', width:80,align:'center'},
            {field:'csdt_name',title:'{:LANG('csdt_name')}', width:120,align:'center'},
            {field:'csdt_catg1',title:'调蓄池大类', width:150,align:'center'},
            {field:'csdt_catg2',title:'调蓄池小类', width:150,align:'center'},
            {field:'csdt_address',title:'调蓄池地址', width:150,align:'center'},
            {field:'csdt_point',title:'{:LANG('gps_point')}', width:150,align:'center'},
            {field:'csdt_opr',title:'{:LANG('opr')}', width:150,align:'center'},

        ]],
            pagination:true,
            rownumbers:true,
            singleSelect:false,
            toolbar: '#toolbar',
//            onDblClickRow: function(rowIndex, rowData) {
//            open_window(edit_title, '__URL__/edit?id='+rowData.id);
//        },
            onSelect: function(rowIndex, rowData) {
            var now_rows = jQuery('#dg').datagrid('getSelections');
            if(now_rows.length > 1){
                $("#edit_button").linkbutton('disable');
            }
        },
        onUnselect: function(rowIndex, rowData) {
            var now_rows = jQuery('#dg').datagrid('getSelections');
            if(now_rows.length < 2){
                $("#edit_button").linkbutton('enable');
            }
        },
        });
        //按钮事件绑定
        $('#add_button').click(function(){
            open_window(add_title, '__URL__/add');
        });
        $('#edit_button').click(function(){
            var id = jQuery('#dg').datagrid('getSelected');
            if(!id){
                msgShow('{:LANG('tips')}', '{:LANG('pls_slet_row')}', 'warning');
            }
            open_window('edit_title', '__URL__/edit?id='+id.id);
        });
        $('#del_button').click(function(){
            var id = jQuery('#dg').datagrid('getSelected');
            if(!id){
                msgShow('{:LANG('tips')}', '{:LANG('pls_slet_row')}', 'warning');
            }
            var ids = jQuery('#dg').datagrid('getSelections');
            var s = '';
            for(var i=0;i<ids.length;i++){
                s += ids[i].id+',';
            }

            $.post("__URL__/deleteArray",{"ids":s}, function(result){
                console.log(result);
                if(result == 1){
                    flowShow('{:LANG('tips')}', '{:LANG('delete_success')}');
                } else if(result == 0){
                    msgShow('{:LANG('tips')}', '{:LANG('delete_error')}', 'error');
                }

            });
        });
        $('#search_button').click(function(){
            $('#query_form').toggle();
            $('#dg').datagrid("resize");
        });
        $('#reload_button').click(function(){
            $('#dg').datagrid('load', {});
//                window.location.href = window.location.href;
        });
        $('#reload_clear').click(function(){
            $('#dg').datagrid('clearSelections');
        });

        $('#query_button').click(function(){
            var obj = $('#query_form').serializeJson();
            $('#dg').datagrid('load',obj);
        });
        });
        $('#query_form').hide();


    </script>
</block>
